cmake_minimum_required(VERSION 3.28)
project(simple_protocol)

# 添加子目录 pybind11
add_subdirectory(./lib/pybind11)
add_subdirectory(./lib/simple_protocol)

# 加入cpp文件
pybind11_add_module(simple_protocol SHARED ./src/simple_protocol_export.cpp)

# 添加源文件
# set(SOURCE_FILES
#     .lib/simple_protocol/src/simple_protocol.cpp
# )

# add_library(simple_protocol ${SOURCE_FILES})


# 设置输出文件后缀名为 .pyd
set_target_properties(simple_protocol PROPERTIES SUFFIX ".pyd")

# 添加包含目录
include_directories(
    "include\\**"
    "src\\**"
    "lib\\pybind11\\pybind11\\include"
    "lib\\simple_protocol\\include"
    "C:\\Users\\OSD\\AppData\\Local\\Programs\\Python\\Python312\\libs"
)

set(PYTHON3_LIB "C:\\Users\\OSD\\AppData\\Local\\Programs\\Python\\Python312\\libs\\python3.lib")
set(PYTHON312_LIB "C:\\Users\\OSD\\AppData\\Local\\Programs\\Python\\Python312\\libs\\python312.lib")

# 添加库目录
set(PYTHON_LIB_DIR "C:\\Users\\OSD\\AppData\\Local\\Programs\\Python\\Python312\\libs")
find_library(PYTHON3_LIB python3 PATHS ${PYTHON_LIB_DIR})
find_library(PYTHON312_LIB python312 PATHS ${PYTHON_LIB_DIR})
link_directories(${PTTHON_LIB_DIR})

# 添加依赖项
target_link_libraries(simple_protocol 
PRIVATE 
    simple_protocol_lib 
PUBLIC
    ${PYTHON3_LIB}
    ${PYTHON312_LIB}
)
